package com.betterjr.modules.wechat.handler.url;

import java.util.List;

import org.apache.commons.lang3.StringUtils;

import com.betterjr.common.utils.Collections3;
import com.betterjr.modules.wechat.dispatcher.UrlControl;

public class ReceivableAuditUriHandler implements UrlHandler {

    public static final String RECEIVABLE_AUDIT_FUNC_CODE = "42";

    @Override
    public void handle(String anState, UrlControl anUrlControl) throws Exception {

        final String func = anUrlControl.getParam(UrlControl.FUNC_CODE);

        if (StringUtils.equals(func, RECEIVABLE_AUDIT_FUNC_CODE)) {
            final List<String> params = anUrlControl.getParam(UrlControl.FUNC_PARAMS);

            StringBuilder sb = new StringBuilder();
            if (!Collections3.isEmpty(params)) {
                for (String str : params) {

                    sb.append(str);
                }
                final String id = sb.toString();
                anUrlControl.setUrl("./wechat/index.html#/recieve/detail/unFi/" + id);
            }

            // ScfElecAgreement agreement = agreementService.findOneElecAgreement(requestNo);

        }

        anUrlControl.nextHandler();

    }

}
